| Total Complexity | 12 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import {chat_v1 as chatV1} from 'googleapis/build/src/apis/chat/v1'; |
||
| 3 | |||
| 4 | export default abstract class BaseHandler { |
||
| 5 | protected event: chatV1.Schema$DeprecatedEvent; |
||
| 6 | |||
| 7 | constructor(event: chatV1.Schema$DeprecatedEvent) { |
||
| 8 | this.event = event; |
||
| 9 | } |
||
| 10 | |||
| 11 | protected getAnnotations(): chatV1.Schema$Annotation[] { |
||
| 12 | return this.event.message?.annotations ?? []; |
||
| 13 | } |
||
| 14 | |||
| 15 | protected getAnnotationByType(type: string): chatV1.Schema$Annotation | undefined { |
||
| 16 | return this.getAnnotations().find((annotation) => annotation.type === type); |
||
| 17 | } |
||
| 18 | |||
| 19 | protected getUserTimezone(): LocaleTimezone { |
||
| 20 | if (this.event.common?.timeZone?.id) { |
||
| 21 | const locale = this.event.common.userLocale; |
||
| 22 | const id = this.event.common.timeZone.id; |
||
| 23 | const offset = this.event.common.timeZone.offset ?? 0; |
||
| 24 | return {locale, id, offset}; |
||
| 25 | } |
||
| 26 | |||
| 27 | return {'locale': 'en', 'offset': 0, 'id': 'UTC'}; |
||
| 28 | } |
||
| 29 | |||
| 30 | public abstract process(): chatV1.Schema$Message | Promise<chatV1.Schema$Message>; |
||
| 31 | } |
||
| 32 |